<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>泥头车企业管理</title>
</head>
<body>
<div class="datagrid-header" id="corp-grid-toolbar" style="width: 100%;">
    <table class="datagrid-htable" border="0" cellspacing="0" cellpadding="0" style="width:100%;">
        <tr class="datagrid-header-row" style="height: 30px;">
            <td align="left" style="border-style: solid; padding-left: 48px;">
                企业名称：
                <input style="width: 270px;" class="easyui-combobox" data-options="url:'${springMacroRequestContext.contextPath}/json/local.json',textField:'text',valueField:'value'">
            </td>

            <td align="left" style="border-style: solid;padding-left: 24px;">
                企业类型：
                <select id="corpType" name="corpType" style="width: 87px;">
                    <option value="">请选择</option>
                    <option value="">泥头车企业</option>
                    <option value="">罐式车企业</option>
                </select>
            </td>

            <td align="left" style="border-style: solid;">
                是否本地：
                <select id="ifLocal" name="ifLocal" style="width: 87px;">
                    <option value="">请选择</option>
                    <option value="0">异地</option>
                    <option value="1">本地</option>
                </select>
            </td>
        </tr>

        <tr class="datagrid-header-row" style="height: 30px;">
            <td align="left" style="border-style: solid;">
                挂靠深圳企业名称：
                <input style="width: 270px;" class="easyui-combobox" data-options="url:'${springMacroRequestContext.contextPath}/json/local2.json',textField:'text',valueField:'value'">
            </td>

            <td align="left" style="border-style: solid;">
                实际经营区域：
                <select id="actOpeArea" name="actOpeArea" style="width: 87px;">
                    <option value="">请选择</option>
                    <option value="440303">罗湖区</option>
                    <option value="440304">福田区</option>
                    <option value="440305">南山区</option>
                    <option value="440306">宝安区</option>
                    <option value="440307">龙岗区</option>
                    <option value="440308">盐田区</option>
                </select>
            </td>

            <td align="left" style="border-style: solid;">
                有效状态：
                <select id="state" name="state" style="width: 87px;">
                    <option value="">请选择</option>
                    <option value="0">无效</option>
                    <option value="1">有效</option>
                </select>
            </td>
        </tr>

        <tr class="datagrid-header-row" style="height: 40px;">
            <td colspan="6" align="left" style="border-style: solid;">
                <a href="javascript:void(0)" id="corp-grid-add" class="easyui-linkbutton" data-options="iconCls:'icon-add'">增加</a>
                <a href="javascript:void(0)" id="corp-grid-delete" class="easyui-linkbutton" data-options="iconCls:'icon-remove'">删除</a>
                <a href="javascript:void(0)" id="corp-grid-edit" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">编辑</a>
                <a href="javascript:void(0)" id="corp-grid-state" class="easyui-linkbutton" data-options="iconCls:'icon-state'">有效状态编辑</a>
                <a href="javascript:void(0)" id="corp-grid-area" class="easyui-linkbutton" data-options="iconCls:'icon-area'">实际经营区域编辑</a>
                <a href="javascript:void(0)" id="corp-grid-search" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
                <select  onchange="func()" style="width: 87px;">
                    <option value="0">请选择</option>
                    <option value="1">按名字查询</option>
                    <option value="2">按性别查询</option>
                </select>
            </td>
        </tr>
    </table>
</div>

<table id="corp-grid"></table>

<div id="corp-menu" class="easyui-menu" style="width:160px;">
    <div id="corp-menu-view" data-options="iconCls:'icon-search'">查看</div>
    <div id="corp-menu-delete" data-options="iconCls:'icon-remove'">删除</div>
    <div data-options="iconCls:'icon-edit'">
        <span>编辑</span>
        <div>
            <div id="corp-menu-info" data-options="iconCls:'icon-info'">企业信息</div>
            <div id="corp-menu-state" data-options="iconCls:'icon-state'">有效状态</div>
            <div id="corp-menu-area" data-options="iconCls:'icon-area'">实际经营区域</div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function func(){
        var vs = $('select  option:selected').val();
        alert(vs);
    }
    $(function(){

        $("#corp-grid").datagrid({
            title:"泥头车企业管理",
            toolbar:"#corp-grid-toolbar",
            border:false,
            fit:true,
            width:$(window).width()-252,
            columns:[[
                {field:"ckb",checkbox:true},
                {field:"id",title:"id",width:200,halign:"center",align:"center",resizable:true},
                {field:"name",title:"用户名",width:200,halign:"center",align:"center",resizable:true},
                {field:"userId",title:"用户id",width:80,align:"center",resizable:false},
                {field:"userAccount",title:"账号",width:80,align:"center",resizable:false},
                {field:"password",title:"密码",width:80,align:"center",resizable:false},
                {field:"sex",title:"性别",width:80,align:"center",resizable:false},
                {field:"address",title:"地址",width:80,align:"center",resizable:false},
                {field:"depaId",title:"部门号",width:80,align:"center",resizable:false}

            ]],
            //striped:true,
            fitColumns:true,
            //autoRowHeight:true,
            rownumbers:false,
            singleSelect:false,
            ctrlSelect:true,
            pagination:true,
            pageSize:10,
            pageList:[5,10,15,20,25,30],
            sortName:"corpId",
            sortOrder:"desc",
            url:"${springMacroRequestContext.contextPath}/user/list",
            method:"get",
            loadMsg:"加载数据中，请稍后",
            onDblClickRow:function(rowIndex, rowData){
                var selTr = $("#corp-grid").datagrid("getSelections");
                openDialog({
                    type:"view",
                    title:"泥头车企业信息查看",
                    width:800,
                    height:400,
                    maximizable:true,
                    href:"${springMacroRequestContext.contextPath}/user/getUser?id="+selTr[0].id
                });
            },
            onRowContextMenu:function(e, rowIndex, rowData){
                e.preventDefault();

                $(this).datagrid("unselectAll");

                $(this).datagrid("selectRow", rowIndex);

                $("#corp-menu").menu("show",{
                    left:event.pageX,
                    top:event.pageY
                });
            }
        }).datagrid("columnMoving")
                .datagrid("columnHiding");


        //相关功能按钮事件
        $("#corp-grid-search").click(function(){
            $("#corp-grid").datagrid("load",{
                corpId:$("#corpId").val(),
                linkedCorpId:$("#linkedCorpId").val(),
                actOpeArea:$("#actOpeArea").val(),
                ifLocal:$("#ifLocal").val(),
                state:$("#state").val()
            });
        });

        $("#corp-grid-add").click(function(){
            openDialog({
                title:"泥头车企业信息添加",
                width:800,
                height:360,
                maximizable:false,
                href:"${springMacroRequestContext.contextPath}/html/user/userAdd.html"
            });
        });

        $("#corp-grid-delete").click(function(){
            var selTr = $("#corp-grid").datagrid("getSelections");

            if(selTr.length == 0){
                Messager.alert({
                    type:"info",
                    title:"&nbsp;",
                    content:"请至少选择1条记录"
                });
            }else{
                var strIds = "";
                //拼接字符串，这里也可以使用数组，作用一样
                for (var i = 0; i < selTr.length; i++) {
                    strIds += selTr[i].id + ",";
                }
                $.ajax({
                    url : '${springMacroRequestContext.contextPath}/user/delete?ids='+strIds,
                    dataType : 'json',
                    type : 'delete',
                    success : function(data) {
                        Messager.show({
                            title:"&nbsp;",
                            content:"删除成功"
                        });

                    },
                    error : function(data) {
                        Messager.show({
                            title:"&nbsp;",
                            content:"删除失败"
                        });
                    }
                });

            }
        });

        $("#corp-grid-edit").click(function(){
            var selTr = $("#corp-grid").datagrid("getSelections");

            var infoMsg = null;

            infoMsg = selTr.length < 1 ? "请选择一条记录" : (selTr.length > 1 ? "最多只能选择一条记录" : null);

            if(null != infoMsg){
                Messager.alert({
                    type:"info",
                    title:"&nbsp;",
                    content:infoMsg
                });
            }else{
                openDialog({
                    title:"泥头车企业信息编辑",
                    width:800,
                    height:360,
                    maximizable:false,
                    href:"user/toModify?id="+selTr[0].id
                });
            }
        });

        $("#corp-grid-area").click(function(){
            var selTr = $("#corp-grid").datagrid("getSelections");

            var infoMsg = null;

            infoMsg = selTr.length < 1 ? "请选择一条记录" : (selTr.length > 1 ? "最多只能选择一条记录" : null);

            if(null != infoMsg){
                Messager.alert({
                    type:"info",
                    title:"&nbsp;",
                    content:infoMsg
                });
            }else{
                openDialog({
                    title:"泥头车企业实际经营区域编辑",
                    width:500,
                    height:280,
                    maximizable:false,
                    href:"BaseInfo/Corp/CorpAreaEdit.html"
                });
            }
        });

        $("#corp-grid-state").click(function(){
            var selTr = $("#corp-grid").datagrid("getSelections");

            var infoMsg = null;

            infoMsg = selTr.length < 1 ? "请选择一条记录" : (selTr.length > 1 ? "最多只能选择一条记录" : null);

            if(null != infoMsg){
                Messager.alert({
                    type:"info",
                    title:"&nbsp;",
                    content:infoMsg
                });
            }else{
                openDialog({
                    title:"泥头车企业有效状态编辑",
                    width:500,
                    height:320,
                    maximizable:false,
                    href:"BaseInfo/Corp/CorpStateEdit.html"
                });
            }
        });


        //菜单相关按钮事件
        $("#corp-menu-view").click(function(){
            new($("#corp-grid").datagrid("options").onDblClickRow);
        });

        $("#corp-menu-delete").click(function(){
            $("#corp-grid-delete").click();
        });

        $("#corp-menu-info").click(function(){
            $("#corp-grid-edit").click();
        });

        $("#corp-menu-area").click(function(){
            $("#corp-grid-area").click();
        });

        $("#corp-menu-state").click(function(){
            $("#corp-grid-state").click();
        });
    });
</script>
</body>
</html>